package 每日一题OJ;

/**
 * @author shy_black
 * @date 2019/8/20 22:11
 * @Description:
 */
public class _70_爬楼梯 {
    public int climbStairs(int n) {
        int a = 1;
        int b = 1;
        int tmp = 0;
        if(n <= 2)
            return n;
        for(int i = 1;i < n;i++) {
            tmp = a + b;
            a = b;
            b = tmp;
        }
        return tmp;



        //递归，leetcode超出时间限制
        // if(n <= 2)
        //     return n;
        // return climbStairs(n-1) + climbStairs(n-2);
    }
}